package com.baidu.shop.base;

import com.baidu.shop.utils.StringUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;


/**
 * @Description:
 * @ClassName: BaseDTO
 * @Author: User
 * @date: 2020.08.31 19:06
 * @version: 1.0
 */
@Data
@ApiModel(value = "BaseDTO用于数据传输,其他dto需要继承此类")
public class BaseDTO {

    @ApiModelProperty(value = "当前页", example = "1")
    private Integer page;

    @ApiModelProperty(value = "每页显示多少条",example = "5")
    private Integer pagesize;

    @ApiModelProperty(value = "排序字段")
    private String sort;

    @ApiModelProperty(value = "是否升序")
    private boolean desc;


    @ApiModelProperty(hidden = true)
    public String getOrderByClause(){
           if (StringUtil.isNotEmpty(sort)){
               return sort+" "+(desc?"desc":"");
           }
           return null;
    }
}
